#!/bin/sh

# sqlalchemy所需材料:
# Python-2.7.6.tgz
# SQLAlchemy-0.9.4.tar.gz

export home=/usr/tmp/sqlalchemy.install/
cd /root/install/nginx/openssl-1.0.1g && ./config && make && make install && ldconfig && ldconfig -p | grep ssl
rm -fr /usr/local/Python-2.7.6
tar -zxf Python-2.7.6.tgz && cd Python-2.7.6 && ./configure --prefix=/usr/local/Python-2.7.6 && make && make install
export PATH=/usr/local/Python-2.7.6/bin/:$PATH:/usr/local/mysql/bin/
python -c "from urllib2 import HTTPSHandler" #确定openssl其作用了
python -V #2.7.6
tar -zxf setuptools-0.9.8.tar.gz && cd setuptools-0.9.8 && python setup.py install
tar -zxf pip-1.4.tar.gz && cd pip-1.4 && python setup.py install
pip #确定pip已经安装好, openssl是否安装会影响pip
tar -zxf SQLAlchemy-0.9.4.tar.gz && cd SQLAlchemy-0.9.4 && python setup.py install
python -c "import sqlalchemy"
tar -xf MySQL-python-1.2.5.tar && cd MySQL-python-1.2.5 && python setup.py install
echo /usr/local/mysql/lib/ > /etc/ld.so.conf.d/mysql.conf && ldconfig && ldconfig -p | grep mysql
python -c "from sqlalchemy import create_engine; engine = create_engine('mysql://u2:p2@127.0.0.1/CHG'); conn=engine.connect()" | grep "Can't connect to MySQL server"
# 不报错:ImportError: No module named MySQLdb，
# 报错:sqlalchemy.exc.OperationalError: (OperationalError) (1045, "Access denied for user 'u2'@'127.0.0.1' (using password: NO)") None None
# 证明是ok的
pip install --upgrade distribute
pip install -r install.pip
# install.pip里面也安装了SQLAlchemy，所以需要进一步改造install.pip为全源码安装。
tar -zxf memcached-1.4.15.tar.gz && cd memcached-1.4.15 && ./configure --prefix=/usr/local/memcached-1.4.15 && make && make install
ln -s /usr/local/memcached-1.4.15 /usr/local/memcached
tar -zxf libmemcached-0.40.tar.gz && cd libmemcached-0.40 && ./configure --with-memcached=/usr/local/memcached/bin/memcached && make && make install
pip install pyramid -i http://mirrors.aliyun.com/pypi/simple/
pip install requests -i http://mirrors.aliyun.com/pypi/simple/
# 某一个site的python setup.py install 会读取 setup.py/requires 来进行安装
# 收到错误pkg_resources.DistributionNotFound: gunicorn :
#  pip install gunicorn

# ImportError: No module named pyramid_exclog
pip install pyramid_exclog

config.get_jinja2_environment().globals['STATIC_FILE_VERSION'] = static_file_version
如果UserCenterWebService/__init__.py:报错:
AttributeError: 'NoneType' object has no attribute 'globals'
把 config.commit() 加到 config.get_jinja2_environment 的上一句:
config.commit()
config.get_jinja2_environment().globals['STATIC_FILE_VERSION'] = static_file_version

# UserCenterWebService/__init__.py
# config.add_jinja2_search_path('UserCenterWebService:templates/') 写死了 要想法
pip install simplejson